package demo08;

import java.net.MalformedURLException;
import java.net.URL;

public class URLDemo01 {
    public static void main(String[] args) {
        try {
            URL url = new URL("http:localhost:8080helloworldindex.jsp? username=kuangshen&password=123");
            System.out.println(url.getProtocol());
//            获取URL的协议名
            System.out.println(url.getHost());
//            获取URL的主机名
            System.out.println(url.getPort());
//            获取URL的端口号
            System.out.println(url.getPath());
//            获取URL的文件路径
            System.out.println(url.getFile());
//            获取URL的文件名
            System.out.println(url.getQuery());
//            获取URL的查询名
        } catch (MalformedURLException e) {
            e.printStackTrace();
        }
    }


}
